define("matrixGallery",["lodash","skins","core","santaProps","utils","coreUtils","galleriesCommon","displayer"],function(a,b,c,d,e,f,g,h){"use strict";var i=c.compMixins;var j=f.matrix.calculations;var k=f.matrix.scalingCalculations;var l=g.utils.galleriesHelperFunctions;var m=e.galleriesCommonLayout;var n=70;var o=["topPadding","imgHeightDiff"];function p(a,b,c){return c<=a*b?"fullView":"hiddenChildren"}function q(a){return Math.max(n,a)}function r(b,c){if(b&&c&&b.skin===c.skin){var d=a.pick(b.style.properties,o);var e=a.pick(c.style.properties,o);return!a.isEqual(d,e)}return false}return{displayName:"MatrixGallery",propTypes:a.assign({shouldResetGalleryToOriginalState:d.Types.RenderFlags.shouldResetGalleryToOriginalState.isRequired,compProp:d.Types.Component.compProp.isRequired,compData:d.Types.Component.compData.isRequired,style:d.Types.Component.style.isRequired,skin:d.Types.Component.skin.isRequired,compTheme:d.Types.Component.theme,currentUrlPageId:d.Types.Component.currentUrlPageId.isRequired,isMobileView:d.Types.isMobileView,isMobileDevice:d.Types.Device.isMobileDevice,isTabletDevice:d.Types.Device.isTabletDevice,compActions:d.Types.Component.compActions.isRequired},d.santaTypesUtils.getSantaTypesByDefinition(h)),statics:{useSantaTypes:true},mixins:[i.skinBasedComp,i.skinInfo],getInitialState:function(){this.shouldResetGalleryToOriginalState=this.props.shouldResetGalleryToOriginalState;var a=j.getAvailableRowsNumber(this.props.compProp.maxRows,this.props.compProp.numCols,this.props.compData.items.length);var b=this.props.isMobileView?"mobileView":"desktopView";this.showMoreClicked=false;this.galleryHeight=q(this.props.style.height);this.itemHeight=j.getItemHeight(this.props.compProp.margin,this.galleryHeight,a,l.getSkinHeightDiff(this.props.skin));return{numberOfRows:a,$mobile:this.props.isMobileDevice||this.props.isTabletDevice?"mobile":"notMobile",$displayDevice:b,$state:p(a,this.props.compProp.numCols,this.props.compData.items.length)}},createDisplayer:function(a,c,d,e){var f=this.getDisplayerSkin();var g=b.skins[this.props.skin];var h=g.exports&&g.exports.bottomGap||0;var i=this.getParams(o,f);var m=l.getDisplayerHeightDiff(b.skins[f],i,this.state.$displayDevice);var n=l.getDisplayerWidthDiff(b.skins[f],this.state.$displayDevice);var p=k.getSizeAfterScaling({itemHeight:e,itemWidth:d,displayerData:a,imageMode:this.props.compProp.imageMode,widthDiff:n,heightDiff:m,bottomGap:h});var q=j.getItemPosition(c,d,e,this.props.compProp.margin,this.props.compProp.numCols);return this.createChildComponent(a,"wysiwyg.viewer.components.Displayer","imageItem",{key:a.id,ref:this.props.id+a.id+c,id:this.props.id+a.id+c,currentUrlPageId:this.props.currentUrlPageId,galleryId:this.props.id,galleryDataId:this.props.compData.id,imageWrapperSize:p.imageWrapperSize,imageIndex:c,heightDiff:m,widthDiff:n,bottomGap:h,compActions:this.props.compActions,style:{width:p.displayerSize.width,height:p.displayerSize.height,position:"absolute",left:q.left,top:q.top}})},createDisplayers:function(){var b=a.take(this.props.compData.items,this.props.compProp.numCols*this.state.numberOfRows);var c=j.getItemWidth(this.props.compProp.margin,this.props.compProp.numCols,this.props.style.width,l.getSkinWidthDiff(this.props.skin));var d=this.itemHeight||j.getItemHeight(this.props.compProp.margin,this.galleryHeight,this.state.numberOfRows,l.getSkinHeightDiff(this.props.skin));return a.map(b,function(a,b){return this.createDisplayer(a,b,c,d)}.bind(this))},componentWillReceiveProps:function(b){var c=j.getAvailableRowsNumber(b.compProp.maxRows,b.compProp.numCols,b.compData.items.length);var d={};var e=false;if(this.props.compProp.maxRows!==b.compProp.maxRows||this.props.compProp.numCols!==b.compProp.numCols||this.props.compData.items.length!==b.compData.items.length){e=true;d.numberOfRows=c;this.galleryHeight=q(l.getGalleryHeight(this.state.numberOfRows,c,this.props.compProp.margin,this.props.skin,this.galleryHeight));d.$state=p(c,b.compProp.numCols,b.compData.items.length)}if(this.props.style.height!==b.style.height){e=true;this.galleryHeight=q(b.style.height)}if(this.shouldResetGalleryToOriginalState!==b.shouldResetGalleryToOriginalState){if(this.shouldResetGalleryToOriginalState&&this.resetGalleryState){this.resetGalleryState()}this.shouldResetGalleryToOriginalState=b.shouldResetGalleryToOriginalState}if(e||r(this.props.compTheme,b.compTheme)){this.itemHeight=j.getItemHeight(b.compProp.margin,this.galleryHeight,c,l.getSkinHeightDiff(this.props.skin));var f=l.getSkinHeightDiff(this.props.skin);this.galleryHeight=this.state.numberOfRows*this.itemHeight+(this.state.numberOfRows-1)*this.props.compProp.margin+f}if(!a.isEmpty(d)){this.setState(d)}},getSkinProperties:function(){var a={showMore:{children:this.props.compProp.showMoreLabel,onClick:this.showMoreRows},itemsContainer:{children:this.createDisplayers(),style:{height:this.galleryHeight}},"":{"data-height-diff":l.getSkinHeightDiff(this.props.skin),"data-width-diff":l.getSkinWidthDiff(this.props.skin),"data-presented-row":this.state.numberOfRows,style:{height:this.galleryHeight}}};if(this.showMoreClicked||this.state.$state==="fullView"){m.updateSkinPropsForFlexibleHeightGallery(a,this.galleryHeight)}return a},showMoreRows:function(){var a=j.getAvailableRowsNumber(this.state.numberOfRows+this.props.compProp.incRows,this.props.compProp.numCols,this.props.compData.items.length);this.showMoreClicked=true;this.galleryHeight=q(l.getGalleryHeight(this.state.numberOfRows,a,this.props.compProp.margin,this.props.skin,this.galleryHeight));this.registerReLayout();this.setState({numberOfRows:a,$state:p(a,this.props.compProp.numCols,this.props.compData.items.length)})},getDisplayerSkin:function(){return this.getSkinExports().imageItem.skin}}});